#ifndef Tui_TMaskPanel_h
#define Tui_TMaskPanel_h


#include "TBase.h"


class TMaskContainer :public CCNode{
public:
    CREATE_FUNC(TMaskContainer);
    
    virtual bool init();
    
    virtual void visit();
    
    virtual void  afterDraw();
    
    virtual void  beforeDraw();
      
     
    
};


class TPanel;

class TMaskPanel:public TPanel{
    
public:
    
    TMaskPanel();
    
    virtual bool init();
    
    CREATE_FUNC(TMaskPanel);
    
    virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent);
    
    DEV_PROPERTY_READONLY(int ,m_nRealContainerHeight,RealContainerHeight);
    
    DEV_PROPERTY_READONLY(int ,m_nRealContainerWidth,RealContainerWidth);
     
    
    DEV_PROPERTY_READONLY(TMaskContainer*  ,m_pContainer, Container);
    
    void calculateRealHeight(int minHeight=0);
    
    void calculateRealWidth();
    
    virtual  void initWidthConf(xml_node<> * pItem);
    
    
    void moveToPos(const CCPoint& pos,bool check=false);
    void moveToBottom();
    void moveToTop();
    
    void checkVisible();
    int renderStartTag;
};




enum TScrollDirection{
    
    TScrollV,
    TScrollH,
    
};

class TScrollPanel:public TMaskPanel{
public:
    CREATE_FUNC(TScrollPanel);
    
    virtual bool init();
     
    
    virtual void onEnter();
    virtual void onExit();
    static TScrollPanel* create(xml_node<> * pItem);
    virtual  void initWidthConf(xml_node<> * pItem);
    
    virtual void addChild(CCNode * child);
    TPanelItem* getItemByTag(int tag);
    
    virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent);
    
    virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent);
    
    
    DEV_PROPERTY(bool, m_bIsScroll, IsScroll);
    
    
    void onMoveEnd();
    
    DEV_PROPERTY(TScrollDirection , m_nDirection, Direction);

    void moveToBottom();
    void moveToPos(const CCPoint& pos,bool check=false);
    void moveToTop();
protected: 
    bool isCheckBottom;

};


#endif
